import tinymce from 'tinymce/tinymce'
import { checkBeforeInsert, emit } from '@/utils/helpers'

tinymce.PluginManager.add('docContent', function (editor) {
  return (
    editor.ui.registry.addMenuItem('docContent', {
      text: '文件内容',
      onAction: function () {
        if (!checkBeforeInsert('docContent')) return
        emit('show-docContent-insert-dialog')
      }
    }),
    {
      getMetadata: function () {
        return {
          name: '文件内容',
          url: 'http://sfrj.cn'
        }
      }
    }
  )
})
